﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace RilattackLibrary
{
    public abstract class GraphicObject : Actor, IMovable
    {
        public struct Vect2
        {
            public int x;
            public int y;
        };
        public Rectangle Source { get; set; }
        public Rectangle Dest { get; set; }
        public Texture2D Image { get; set; }
        public Vect2 MovementDirection;

        public void GetPosition(out int x, out int y)
        {
            x = Dest.X;
            y = Dest.Y;
        }

        public void SetRect(int x, int y, int width, int height)
        {
            Dest = new Rectangle(x, y, width, height);
        }

        public void SetPosition(int x, int y)
        {
            Dest = new Rectangle(x, y, Dest.Width, Dest.Height);
        }

        public void MoveBy(int x, int y)
        {
            Dest = new Rectangle(Dest.X + x, Dest.Y + y, Dest.Width, Dest.Height);
        }

        public void AplyXMovementDirection()
        {
            Dest = new Rectangle(Dest.X + MovementDirection.x, Dest.Y, Dest.Width, Dest.Height);
        }

        public void AplyYMovementDirection()
        {
            Dest = new Rectangle(Dest.X, Dest.Y + MovementDirection.y, Dest.Width, Dest.Height);
        }

        public override void Play(SpriteBatch spriteBatch)
        {
            spriteBatch.Begin();
            spriteBatch.Draw(Image, Dest, Source, Color.White);
            spriteBatch.End();
        }
    }
}